//vue初始化


var vue;
function vue_init() {
    // Vue.config.unsafeDelimiters = ['{{{','}}}'];
    Vue.config.delimiters = ['{!', '!}']
    vue = new Vue({
        el: "#app",
        data: {
            placard: "公告",
            avatar:avatar,
            user_money: balance,
            couponnumber: couponnumber,//卷数量
            use_voucher:use_voucher,
            pdata: pageData,//页面数据
            pi: 0,//当前页面索引
            select_good: "",//选择的产品名称
            select_time: 0,//选择的时间
            dir: true,//当前选中方向 true 涨 false 跌
            map_time_name: "M1",//分时图选择名称
            map_time: "1",//分时图选择
            map_type: "l",//分时图选择
            type_prices: null,//当前所有价格列表
            type_name: "",//选择的产品类型
            transactions_num: 0,//买卖次数
            last_time_f:null,
        },
        events: {
            /*'openlist': function (msg) {//监听是否弹出持仓单
                this.$broadcast('openlist', msg);
            },*/
            'new_order':function (msg) {
                // this.pdata[this.pi].position_order = msg.order;
                // self.pdata[j].data_list[d].list.splice(self.pdata[j].data_list[d].list.length, 0, temp_d);
                this.pdata[this.pi].position_order.splice(0, 0, msg.order);
                this.pdata[this.pi].buy_act_time = msg.buy_act_time;
                addGuide(this.pdata[this.pi].position_order[0], decimal_list[this.pdata[this.pi].code]);
				this.deal_order_time();
                // InitializaChart(this.pdata[this.pi].data_list, this.pdata[this.pi].position_order, this.map_time_name, decimal_list[this.pdata[this.pi].code], this.map_time, this.pdata[this.pi].isRest);
            },
            'buy': function (msg) {
                this.buy(msg.swl)
            },
            'update_user_money': function (msg) {//更新用户金额
                if (msg && msg.money) {
                    this.user_money = parseFloat(msg.money);
                } else {
                    this.update_user_money();
                }
            },
            'reduce_couponnumber': function (msg) {//优惠卷数量减去
                this.couponnumber = parseInt(this.couponnumber - msg.number);
            },
            'up_couponnumber':function (msg) {
                this.up_couponnumber(msg);
            }
        },
        methods: {
            init: function () {//初始化
                this.getDataInfo();
                this.sel_good(0, this.pdata[0].game_name);
                this.deal_order_time();
                // this.abc();
            },
            loadData:function () {
                var t = this;
                loadshow();
                $.post(ROOT+"/minute/getData", {type:t.pdata[t.pi].id, map_time:t.map_time}, function (data) {
                    loadhide();
                    t.pdata[t.pi].data_list[t.map_time_name].list = data.list;
                    InitializaChart(data.list, t.pdata[t.pi].position_order[0], decimal_list[t.pdata[t.pi].code], t.map_type, t.pdata[t.pi].isRest);
                }, "json");
            },
            open_lottery:function (order_no) {
                for (var i=0; i<this.pdata[this.pi].position_order.length; i++) {
                    if (this.pdata[this.pi].position_order[i].order_no == order_no) {
                        this.pdata[this.pi].position_order.splice(i, 1);
                    }
                }
                if (this.pdata[this.pi].position_order.length > 0) {
                    addGuide(this.pdata[this.pi].position_order[0], decimal_list[this.pdata[this.pi].code]);
                } else {
                    delGuide();
                }
                this.update_user_money();
            },
            deal_order_time:function () {
                var self = this;
                if (self.pdata[self.pi].game_name == self.select_good) {
                    var bool = false;
                    for (var i=0; i<self.pdata.length; i++) {
                        if (self.pdata[i].buy_act_time >= 0) {
                            self.pdata[i].buy_act_time--;
                            bool = true;
                        }
                    }
                    /*if (self.pdata[self.pi].buy_act_time >= 0) {
                        this.$broadcast('up_buy_btn_act_time', self.pdata[self.pi].buy_act_time);
                    }*/
                    if (bool == true) {
                        setTimeout(function () {
                            self.deal_order_time();
                        }, 1000);
                    }
                }
            },
            up_couponnumber:function (voucher_num) {
                this.couponnumber = voucher_num;
            },
            set_map: function (str, limit, type) {//分时图选择
                if (this.map_time_name != str) {
                    this.map_time_name = str;
                    this.map_time = limit;
                    this.map_type = type;

                    if (this.pdata[this.pi].data_list[this.map_time_name].list.length == 0) {
                        this.loadData();
                    } else {
                        InitializaChart(this.pdata[this.pi].data_list[this.map_time_name].list, this.pdata[this.pi].position_order[0], decimal_list[this.pdata[this.pi].code], this.map_type, this.pdata[this.pi].isRest);
                    }

                    // alert(this.pdata[this.pi].data_list[this.pdata[this.pi].data_list.length-1].open_value + ":" + this.pdata[this.pi].data_list[this.pdata[this.pi].data_list.length-1].close_value);
                    // InitializaChart(this.pdata[this.pi].data_list, this.pdata[this.pi].position_order, this.map_time_name, decimal_list[this.pdata[this.pi].code], this.map_time, this.pdata[this.pi].isRest);
                }
            },
            map_zoom: function (dir) {//地图缩放
                // setZoom(dir)
            },
            new_update_price: function (data) {
                var self = this;
                var arr = self.type_prices ? self.copy_obj(self.type_prices): [];//设置价格方向
                for (var i=0; i<data.length; i++) {
                    var key = data[i].code;
                    var val = parseFloat(0).toFixed(decimal_list[key]);
                    var high = parseFloat(0).toFixed(decimal_list[key]);
                    var low = parseFloat(0).toFixed(decimal_list[key]);
                    var zuoshou = parseFloat(0).toFixed(decimal_list[key]);
                    var jingkai = parseFloat(0).toFixed(decimal_list[key]);
                    for (var j=0; j<self.pdata.length; j++) {
                        if (self.pdata[j].code == key && self.pdata[j].isRest == 1) {
                            // console.log(self.pdata[j].code + "-----" + key)
                            val = parseFloat(data[i].close_value).toFixed(decimal_list[key]);
                            high = parseFloat(data[i].today_max_value).toFixed(decimal_list[key]);
                            low = parseFloat(data[i].today_min_value).toFixed(decimal_list[key]);
                            zuoshou = parseFloat(data[i].yesterday_close_value).toFixed(decimal_list[key]);
                            jingkai = parseFloat(data[i].today_open_value).toFixed(decimal_list[key]);
                        }
                    }

                    if (val > 0) {
                        // console.log(self.type_prices);
                        if (self.type_prices && self.type_prices[key]) {
                            var dir = self.type_prices[key][1];//上一次的方向
                            if (val > self.type_prices[key][0]) {//涨
                                dir = 1
                            } else if (val < self.type_prices[key][0]) {//跌
                                dir = 2
                            }
                            arr[key] = [val, dir];
                        }
                    } else {
                        arr[key] = ["休盘", 0];
                    }

                    self.set_setting_price(key, 'bid', val);
                    self.set_setting_price(key, 'zuoshou', zuoshou);
                    self.set_setting_price(key, 'jingkai', jingkai);
                    self.set_setting_price(key, 'low', low);
                    self.set_setting_price(key, 'high', high);

                    self.type_prices = arr;

                    for (var j=0; j<self.pdata.length; j++) {
                        if (self.pdata[j].code == key) {
                            for (var d in self.pdata[j].data_list) {
                                if (self.pdata[j].data_list[d].list.length > 0) {
                                    var temp_time1 = self.pdata[j].data_list[d].list[self.pdata[j].data_list[d].list.length-1].begin_time;
                                    var temp_time2 = data[i].time;

                                    var diff_time = TimeDifference(temp_time1, temp_time2);
                                    if (diff_time == self.pdata[self.pi].data_list[d].value) {
                                        // console.log(d+"-------------"+temp_time2+"-"+temp_time1+"="+diff_time);
                                        var temp_d = new Object();
                                        temp_d.open_value = data[i].close_value;
                                        temp_d.close_value = data[i].close_value;
                                        temp_d.max_value = data[i].close_value;
                                        temp_d.min_value = data[i].close_value;
                                        temp_d.begin_time = temp_time2;
                                        var end_time = new Date(temp_time1.replace("-","/"));
                                        end_time.setMinutes(end_time.getMinutes() + diff_time);

                                        temp_d.time = end_time.Format("yyyy-MM-dd hh:mm");

                                        self.pdata[j].data_list[d].list.splice(self.pdata[j].data_list[d].list.length, 0, temp_d);
                                        self.pdata[j].data_list[d].list.splice(0, 1);
                                    }
                                }
                            }
                        }
                    }
                }

                if (self.pdata[self.pi].data_list[self.map_time_name].list.length > 0 && self.pdata[self.pi].data_list[self.map_time_name].type == "l" && self.pdata[self.pi].isRest == 1) {
                    upAmChartsDate(self.pdata[self.pi].data_list[self.map_time_name].list, self.pdata[self.pi].data_list[self.map_time_name].type,decimal_list[self.pdata[self.pi].code]);
                }
            },
            update_price: function (data) {//服务器推数据
                var self = this;
                var arr = self.type_prices ? self.copy_obj(self.type_prices): [];//设置价格方向

                var key = data.code;
                // console.log(data);
                var val = parseFloat(0).toFixed(decimal_list[key]);
                var high = parseFloat(0).toFixed(decimal_list[key]);
                var low = parseFloat(0).toFixed(decimal_list[key]);
                var zuoshou = parseFloat(0).toFixed(decimal_list[key]);
                var jingkai = parseFloat(0).toFixed(decimal_list[key]);
                for (var j=0; j<self.pdata.length; j++) {
                    if (self.pdata[j].code == key && self.pdata[j].isRest == 1) {
                        // console.log(self.pdata[j].code + "-----" + key)
                        val = parseFloat(data.close_value).toFixed(decimal_list[key]);
                        high = parseFloat(data.today_max_value).toFixed(decimal_list[key]);
                        low = parseFloat(data.today_min_value).toFixed(decimal_list[key]);
                        zuoshou = parseFloat(data.yesterday_close_value).toFixed(decimal_list[key]);
                        jingkai = parseFloat(data.today_open_value).toFixed(decimal_list[key]);
                    }
                }

                // var ctm = data.time;
                if (val > 0) {
                    // console.log(self.type_prices);
                    if (self.type_prices && self.type_prices[key]) {
                        var dir = self.type_prices[key][1];//上一次的方向
                        if (val > self.type_prices[key][0]) {//涨
                            dir = 1
                        } else if (val < self.type_prices[key][0]) {//跌
                            dir = 2
                        }
                        arr[key] = [val, dir];
                    }
                } else {
                    arr[key] = ["休盘", 0];
                }

                self.set_setting_price(key, 'bid', val);
                self.set_setting_price(key, 'zuoshou', zuoshou);
                self.set_setting_price(key, 'jingkai', jingkai);
                self.set_setting_price(key, 'low', low);
                self.set_setting_price(key, 'high', high);
                // self.set_setting(key, 'last_time_f', ctm.replace(/-/g, '/'));

                self.type_prices = arr;

                self.$broadcast('money_change', arr);//发送改变金额

                for (var j=0; j<self.pdata.length; j++) {
                    if (self.pdata[j].code == key) {
                        for (var d in self.pdata[j].data_list) {
                            if (self.pdata[j].data_list[d].list.length > 0) {
                                var temp_d = self.pdata[j].data_list[d].list[self.pdata[j].data_list[d].list.length-1];
                                temp_d.close_value = data.close_value;
                                if (data.close_value > temp_d.max_value) {
                                    temp_d.max_value = data.close_value;
                                } else if (data.close_value < temp_d.min_value) {
                                    temp_d.min_value = data.close_value;
                                }
                                self.pdata[j].data_list[d].list[self.pdata[j].data_list[d].list.length-1] = temp_d;
                            }
                        }
                    }
                }

                // console.log(self.map_time_name+"------"+self.pdata[self.pi].data_list[self.map_time_name].type);
                if (self.pdata[self.pi].data_list[self.map_time_name].list.length > 0 && self.pdata[self.pi].data_list[self.map_time_name].type == "l" && self.pdata[self.pi].isRest == 1) {
                    upAmChartsDate(self.pdata[self.pi].data_list[self.map_time_name].list, self.pdata[self.pi].data_list[self.map_time_name].type,decimal_list[self.pdata[self.pi].code]);
                }

            },
            getDataInfo: function () {//轮询获取获取数据
                var self = this;
                // console.log(self.pdata);
                var arr = []; //设置价格方向
                for (var i = 0; i < self.pdata.length; i++) {
                    var vdata = self.pdata[i];
                    var key = vdata.code.toString();//类型名称

                    var val = parseFloat(0).toFixed(decimal_list[key]);
                    var high = parseFloat(0).toFixed(decimal_list[key]);
                    var low = parseFloat(0).toFixed(decimal_list[key]);
                    var zuoshou = parseFloat(0).toFixed(decimal_list[key]);
                    var jingkai = parseFloat(0).toFixed(decimal_list[key]);

                    if (vdata.code == key && vdata.isRest == 1) {
                        val = parseFloat(vdata.bid).toFixed(decimal_list[key]);
                        high = parseFloat(vdata.high).toFixed(decimal_list[key]);
                        low = parseFloat(vdata.low).toFixed(decimal_list[key]);
                        zuoshou = parseFloat(vdata.zuoshou).toFixed(decimal_list[key]);
                        jingkai = parseFloat(vdata.jingkai).toFixed(decimal_list[key]);

                        arr[key] = [val, 1];
                    } else {
                        arr[key] = ["休盘", 0];
                    }

                    self.set_setting_price(key, 'bid', val);
                    self.set_setting_price(key, 'zuoshou', zuoshou);
                    self.set_setting_price(key, 'jingkai', jingkai);
                    self.set_setting_price(key, 'low', low);
                    self.set_setting_price(key, 'high', high);
                }

                self.type_prices = arr;
            },
            charts_update: function (arr) {//更新走势图
                var type = this.pdata[this.pi].code;

                // getNowFormatDate() + " " +
                // console.log(this.pdata[this.pi].last_time_f);
                var sytime = this.pdata[this.pi].last_time_f;

                if (arr[type] && this.map_time == "1") {
                    var close = low = high = open = arr[type][0];
                    charts_update(sytime, {
                        "date": getDataTime(sytime),//时间需要处理
                        "open": open,
                        "high": high,
                        "low": low,
                        "close": close,
                    });
                }
            },
            update_user_money: function (bfun) {//更新用户金额
                var self = this;
                postMsg(ROOT+'/user/getinfo', {field:"balance"}, function (result) {
                    if (result.status == 'ok') {
                        self.user_money = parseFloat(result.balance);
                        if (bfun) bfun();
                    }
                });
            },
            copy_obj: function (obj) {
                var o = $.extend(true, {}, obj);
                return o;
            },
            set_setting_price: function (typename, key, val) {
                val = parseFloat(val);
                val = val.toFixed(decimal_list[typename]);
                if (val == 0) {
                    val = "休盘";
                }
                this.set_setting(typename, key, val);
            },
            set_setting: function (typename, key, val) {//设置对象属性
                for (var i = 0; i < this.pdata.length; i++) {
                    var data = this.pdata[i];
                    if (data.code == typename) {
                        this.pdata[i][key] = val;
                        return data;
                    }
                }
            },
            sel_good: function (index, good) {
                //导航选择产品
                if (this.select_good != good) {
                    this.select_good = good;
                    this.pi = index;
                    // this.map_time_name = "M1";
                    // this.map_time = 1;

                    if (this.pdata[this.pi].data_list[this.map_time_name].list.length == 0) {
                        this.loadData();
                    } else {
                        InitializaChart(this.pdata[this.pi].data_list[this.map_time_name].list, this.pdata[this.pi].position_order[0], decimal_list[this.pdata[this.pi].code], this.map_type, this.pdata[this.pi].isRest);
                    }
                    // this.$broadcast('sel_good', { type: this.pdata[this.pi].code });//发送选择合约事件
                }
            },
            buy: function (swl) {
                if (!check_password()) return;
                //下单
                var i = this.pi;
                var btns = this.pdata[i].money_list;//价格按钮组
                var tid = this.pdata[i].id;//产品ID
                var contact_btns = this.pdata[i].contact_list;//触点按钮
                var max_num = this.pdata[i].max_num;
                var norms = this.pdata[i].norms; // 规格
				
                var msg = {
                    swl: swl,
                    btns: btns,
                    contact_btns:contact_btns,
                    max_num:max_num,
                    norms:norms,
                    code:this.pdata[i].code,
                    select_good: this.select_good,
                    tid: tid,
                    type_name: this.pdata[i].game_name,
                    c_money: this.pdata[i].bid,
                    use_voucher:this.use_voucher,
					buy_btn_act_time:this.pdata[i].buy_act_time
                };
                this.$broadcast('openbuy', msg);
            },
        }
    });
    vue.init();
}


/**
 * Created by Administrator on 2016/8/8.
 */
var mySwipers = [];//所有时间选择器
$(function () {
    vue_init();//双向绑定初始
    initSwiper_menu();

    setInterval(calculationHeight, 50);
});

/*window.onresize=function(){
    calculationHeight();
};*/

function calculationHeight() {
    var windows_h = $(window).height();
    var nav_h = $(".nav").height();

    var app_h = windows_h - nav_h;
    $("#app").height(app_h);

    var header_h = $(".header").outerHeight(true);
    var menu_h = $(".menu").outerHeight(true);
    var buy_btns_h = $(".buy_btns").outerHeight(true);

    var order_list_h = $(".order_list.active").outerHeight(true);

    // alert(order_list_h);

    var main_h = app_h-(header_h+menu_h+buy_btns_h+order_list_h);
    $(".status").outerHeight(main_h);
    var tab_content_h = $(".tab_content").outerHeight(true);

    var trend_chart_h = main_h-tab_content_h;
    $(".trend_chart").outerHeight(trend_chart_h);

    var btns_h = $(".btns").outerHeight(true);
    $(".map").height(trend_chart_h-btns_h);
}

function initSwiper_menu() {//初始化Swiper
    return new Swiper('.menu', {
        slidesPerView : 3,
    })
}

function check_password(){//设置密码
    $("#btnSendCode").removeAttr("disabled");
    var is_set_password = $("#is_set_password").val()
    if (is_set_password == 0) {
        pop_setup_password();
        return false;
    } else if (is_set_password == 2) {
        pop_check_password();
        return false;
    }
    return true;
}

function pop_check_password() {
    alertMsg({
        title: '验证交易密码',
        content: '<div class="login_pop"><div class="psw_top1"><input type="password" id="password" placeholder="请输入交易密码"></div><div class="not1" style="overflow:hidden;"><a onclick="forget_password()" style="float:left;" class="register_text text-red">忘记密码</a><span id="fsyzmtip"></span></div></div>',
        btn: ['确定'],
        yes: function (index, layero) {
            var password = $("#password").val();
            if (password == "") {
                $("#fsyzmtip").html("请输入交易密码！");
                return;
            }
            loadshow();
            $.post(ROOT+"/user/check_password", {password:password}, function (data) {
                loadhide();
                if (data.code == 1) {
                    $("#is_set_password").val(1);
                    layer.close(index);
                } else {
                    $("#fsyzmtip").html(data.msg);
                }
            }, "json");
        }
    });
}

function pop_setup_password() {
    alertMsg({
        title: '设置交易密码',
        content: '<div class="login_pop"><div class="psw_top1"><input type="password" id="password" placeholder="请输入交易密码"></div><div class="psw_top1"><input type="password" id="rep_password" placeholder="请在次输入交易密码"></div><div class="not1" style="overflow:hidden;"><span id="fsyzmtip"></span></div></div>',
        btn: ['确定'],
        yes: function (index, layero) {
            var password = $("#password").val();
            var rep_password = $("#rep_password").val();
            if (password == "") {
                $("#fsyzmtip").html("请输入交易密码！");
                return;
            }
            if (password != rep_password) {
                $("#fsyzmtip").html("两次密码输入不一致！");
                return;
            }
            loadshow();
            $.post(ROOT+"/user/check_password", {password:password}, function (data) {
                loadhide();
                if (data.code == 1) {
                    $("#is_set_password").val(1);
                    layer.close(index);
                } else {
                    $("#fsyzmtip").html(data.msg);
                }
            }, "json");
        }
    });

}

function forget_password() {
    alertMsg({
        title: '找回密码',
        content: '<div class="login_pop"><div class="psw_top1"><input type="tel" id="mobile_phone" class="input_number" placeholder="输入11位手机号码"></div><div class="psw_top1"><input type="password" id="password" placeholder="请输入交易密码"></div><div class="psw_top1"><input type="password" id="repeat_password" placeholder="请确认交易密码"></div><div class="duanxin1 clearfix"><input type="text" id="sms_code" class="code" maxlength="6"  placeholder="请输入短信校验码"><a href="javascript:void(0);" id="btnSendCode" time="120" onclick="SendMsg(\'f\')" class="getcode">获取验证码</a></div><div class="not1" style="overflow:hidden;"><span id="fsyzmtip"></span></div></div>',
        btn: ['确定'],
        yes: function (index, layero) {

            var mobile_phone = $("#mobile_phone").val();
            var sms_code = $("#sms_code").val();
            var password = $("#password").val();
            var repeat_password = $("#repeat_password").val();
            if (null == mobile_phone || mobile_phone == "") {
                $("#fsyzmtip").html("请输入手机号码");
                return;
            }
            if (null == sms_code || sms_code == "") {
                $("#fsyzmtip").html("请输入短信验证码");
                return;
            }
            if (null == password || password == "") {
                $("#fsyzmtip").html("请输入新交易密码");
                return;
            }

            if (password != repeat_password) {
                $("#fsyzmtip").html("两次输入的密码不一致");
                return;
            }

            loadshow();
            $.post(ROOT+"/user/sub_forget_password", { mobile_phone:mobile_phone , password:password, sms_code:sms_code }, function (json) {
                loadhide();
                // var json = eval('(' + result + ')');
                if (json.success==1) {
                    m.alertOK(json.msg, function () {
                        layer.close(index);
                    });
                } else {
                    $("#fsyzmtip").html(json.msg);
                }
            });
        }
    });
}

function ref_yzm(name) {
    var timestamp = new Date().getTime();
    var src = 'verify/get?name='+name + '&'+ timestamp;
    $('#'+name+'_captcha').attr("src", src);
}

function SendMsg(type) {
    $("#fsyzmtip").html("");
    var phone = $("#mobile_phone").val();
    if (phone.trim() == "") {
        $("#fsyzmtip").html("请输入手机号码！");
        return;
    }
    if ($("#btnSendCode").attr("disabled") != "disabled") {
        $("#btnSendCode").attr('disabled', 'disabled');
        loadshow();
        $.post("User/sendSMS", {type: type, mobile_phone: phone}, function(result) {
            loadhide();
            if(result.success == 0)
            {
                $("#fsyzmtip").html("验证码已发送，请注意查收！");
                timer1 = setInterval(function() {SetRemainTime();},1000);
            }
            else
            {
                $("#btnSendCode").removeAttr("disabled");
                $("#fsyzmtip").html(result.msg);
            }
        });
    }
}

function SetRemainTime() {
    $("#btnSendCode").attr("disabled", "disabled");
    var time = $("#btnSendCode").attr("time");
    time = time - 1;
    $("#btnSendCode").attr("time", time);
    $("#btnSendCode").html(time + "秒");
    if (time == 0) {
        $("#btnSendCode").removeAttr("disabled");
        $("#btnSendCode").html("发送验证码");
        $("#btnSendCode").attr("time", 120);
        clearInterval(timer1);
    }
}

// 两个时间相减
function TimeDifference(time1, time2) {
    //定义两个变量time1,time2分别保存开始和结束时间
    // var time1="2009-12-02 12:25";
    // var time2="2009-12-03 12:35";

    //判断开始时间是否大于结束日期
    if(time1>time2) {
        console.log("开始时间不能大于结束时间！");
        return 0;
    }

    //截取字符串，得到日期部分"2009-12-02",用split把字符串分隔成数组
    var begin1=time1.substr(0,10).split("-");
    var end1=time2.substr(0,10).split("-");

    //将拆分的数组重新组合，并实例成化新的日期对象
    var date1=new Date(begin1[1] + - + begin1[2] + - + begin1[0]);
    var date2=new Date(end1[1] + - + end1[2] + - + end1[0]);

    //得到两个日期之间的差值m，以分钟为单位
    //Math.abs(date2-date1)计算出以毫秒为单位的差值
    //Math.abs(date2-date1)/1000得到以秒为单位的差值
    //Math.abs(date2-date1)/1000/60得到以分钟为单位的差值
    var m=parseInt(Math.abs(date2-date1)/1000/60);

    //小时数和分钟数相加得到总的分钟数
    //time1.substr(11,2)截取字符串得到时间的小时数
    //parseInt(time1.substr(11,2))*60把小时数转化成为分钟
    var min1=parseInt(time1.substr(11,2))*60+parseInt(time1.substr(14,2));
    var min2=parseInt(time2.substr(11,2))*60+parseInt(time2.substr(14,2));

    //两个分钟数相减得到时间部分的差值，以分钟为单位
    var n=min2-min1;

    //将日期和时间两个部分计算出来的差值相加，即得到两个时间相减后的分钟数
    var minutes=m+n;
    // document.writeln(minutes);
    return minutes;
}

Date.prototype.Format = function (fmt) { //author: meizz
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "h+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}

Vue.filter('time',
    function(value) {
        var theTime = parseInt(value);// 秒
        var theTime1 = 0;// 分
        var theTime2 = 0;// 小时
        if(theTime > 59) {
            theTime1 = parseInt(theTime/60);
            theTime = parseInt(theTime%60);
            if(theTime1 > 59) {
                theTime2 = parseInt(theTime1/60);
                theTime1 = parseInt(theTime1%60);
            }
        }

        var result = "";
        if(parseInt(theTime2) > 0) {
            if(parseInt(theTime2) < 10) {
                result = "0"+theTime2+":";
            } else {
                result = theTime2+":";
            }
        }

        if(parseInt(theTime1) > 0) {
            if(parseInt(theTime1) < 10) {
                result += "0"+theTime1+":";
            } else {
                result += theTime1+":";
            }
        } else {
            result += "00:";
        }

        if(parseInt(theTime) > 0) {
            if(parseInt(theTime) < 10) {
                result += "0"+theTime;
            } else {
                result += theTime;
            }
        } else {
            result += "00";
        }
        return result;
    }
);